﻿using Bll;
using Help;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Myproject.BSM.Ashx.PcChannelSlide
{
    /// <summary>
    /// SlideEdit 的摘要说明
    /// </summary>
    public class SlideEdit : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string id = context.Request.Form["pc_channel_slideEdit_slideID"];
            string name = context.Request.Form["pc_channel_slideEdit_name"];
            if (id == "0")
            {
                SlideModel model = new SlideModel();
                model.SlideName = name;
                if (new SlideBLL().Add(model) > 0)
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "添加频道成功！", "pc_channel_slidelist", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "添加频道失败！", "pc_channel_slidelist", "", "", true, "", ""));
                }
            }
            else
            {
                SlideModel model = new SlideBLL().GetModel(int.Parse(id));

                model.SlideName = name;
                if (new SlideBLL().Update(model))
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(200, "修改频道成功！", "pc_channel_slidelist", "", "", true, "", ""));
                }
                else
                {
                    context.Response.Write(ReturnJsonHelp.BJUIajaxJson(300, "修改频道失败！", "pc_channel_slidelist", "", "", true, "", ""));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}